{extend name='/layout/layoutname'}
{block name='head'}
	<title>矿机-蚁巢众筹</title>
	<link rel="stylesheet" href="/static/css/Octen_center.css" />
	<style type="text/css">
		.module{
			width: 100%;
			height: 100%
		}
	   	footer{
		   	float: right;
		   	bottom: 0;
		   	top: 100%;
	   	}
		.pay{
            position: fixed;
            top: 25%;
            left: 35%;
			width: 400px;
			text-align: center;
			margin: 0 auto;
			padding: 0 0 60px 0;
			background: #EEEEEE;
			z-index: 998;
			display: none;
		}
		.pay_header{
			height: 45px;
			background: #F6F6F6;
		}
		.pay_header h5{
			display: inline-block;
			text-align: center;
			padding:  0  0px 0px 120px;
			font-size: 18px;
			margin: 10px 0 0 0;
			font-weight: 500;
		}
		.pay_header .pay_header_img{
			display: inline-block;
			text-indent:120px;
			cursor: pointer;
		}
		.pay_body{
			text-align: left;
			padding: 20px;
		}
		.pay_body>input{
			color: #9D9D9D;
		}
		.pay_body>div{
			display: inline-block;
			margin: 0px 0 0 120px;
			vertical-align: ;
		}
		.pay_body>div>img{
			display: inline-block;
			vertical-align: middle;
		}
		.pay_body>div>p{
			display: inline-block;
			padding: 0 10px 0 10px;
			vertical-align: baseline;
		}
		.pay_body button{
			width: 40%;
			height: 45px;
			background: #2CB5F5;
			border: none;
			border-radius: 30px;
			color: #FFFFFF;
			font-size: 18px;
			margin: 60px 0 0 30%;
		}
		#pay_body_p{
			display: inline-block;
		}
	</style>
{/block}
{block name='body'}
	<div class="scroll" id='earnings_scroll'>
		<div class="scroll_picture" id='earnings_bg'>
		{if condition="$user"}
			<div class="sign_out sign preoare_sign">
				<p>账户信息</p>
				<p>
					<span>账户:</span>
					<span>{$user['username'] ? $user['username'] : $user['mobile']}</span>
					<a href="javascript:;" onclick="history.go(0)">刷新</a>
				</p>
				<p>
					<span>总资金:</span>
					<span>{$user['total_funds']}</span>
				</p>
				<p>
					<span>可用资金:</span>
					<span>{$user['available_funds']}</span>
				</p>
				<p>
					<span>佣金:</span>
					<span>{$user['commission']}</span>
				</p>
				<button onclick='signout(this,"{:url('index/index/signout')}")'>安全退出</button>
			</div>
		{else/}
			<div class="sign_in sign preoare_sign">
				<input type="text" name="mobile" class="phone_num input" style="background-color: white;" placeholder="请输入手机号码"/>
				<input type="password" name="password" class="password input" style="background-color: white;" placeholder="请输入密码"/>
				<div class="link">
					<a href="#" class="register">立即注册</a>
				    <a href="#" class="forget_pass">忘记密码?</a>
				</div>
				<input type="button" onclick='signin(this,"{:url('index/index/login')}")' value="登录" class="sign_in_block"/>
			</div>
		{/if}
		</div>
		<div class="notice">
			<div class="official_notice">官网公告</div>
			<span class="notice_title">{$notice[0]['n_title']}</span>
		</div>
	</div>
	<div class="business" id='earnings_business'>
		<div class="pay">
			<div class="pay_header">
				<h5>众筹选择</h5>
				<div class="pay_header_img">
					<img src="/static/img/cancel1.png" id="pay_gb" />
				</div>
			</div>
			<form class="pay_body" method="post">
				<p>
					众筹金额
					<span class="tosum" style="color:#00C2B1;font-size: 18px;"></span>
					元/份
				</p >
				<label for="" >
					<p id="pay_body_p" style="width: 25%;">0</p ><p style="display:inline;">元</p>
				</label>
				<div>
					<img src="/static/img/pay_01.png"/ class="txts">
					<p id="div_p">0</p >
					<img src="/static/img/pay_03.png"/ class="txt">
				</div>
				<div style="margin: 15px 0 0 0px;">
					<input type="number" placeholder="请输入佣金数量" name="own" style="width: 40%;"/>
					<input type="hidden" name="type_id" value="">
					<p style="margin: 0 0 0 80px;">使用佣金</p >
					<input type="radio" class="radio" name="sta" >
					<img src="/static/img/pay_02.png"/ class="radio_img" style="display: none;">
				</div>
				<p style="color: #6D6D6D;">注：佣金数量只能输入一百的整数或倍数才起效</p >
				<div style="margin: 15px 0 0 0px;">
					<p style="margin: 0 0 0 40px;">输入密码</p >
					<input type="text" name="pwd" placeholder="请输入密码" style="width: 40%;"/>
					<!-- <input type="radio" class="radio" >
					<img src="/static/img/pay_02.png"/ class="radio_img" style="display: none;"> -->
				</div>
				<div>
				</div>
				<button onclick="return tofunds()">众筹</button>
			</form>
		</div>
		<div class="main_center center" style="height: auto;">
		    <div>  <!--防止siblings出错-->
				{foreach $group as $val}
				{if condition="$val['data']"}
				<div class="module">
					<div class="module_p">
						<p>{$val.cate_name}</p>
					</div>
					<div class="kjzc">
						{foreach $val['data'] as $v }
						<div class="kjzc_one">
							<div class="kjzc_one_img">
								<img src="/static/img/zckj.jpg"/>
								<p>{$v['type_name']}</p>
							</div>
							<table border="0" cellspacing="0" cellpadding="0">
								<tr>
									<th>总收益</th>
									<th>总周期</th>
									<th>展期</th>
								</tr>
								<tr>
									<td>{$v['candy_num']}</td>
									<td>{$v['lifetime']}天</td>
									<td>{$v['phased']}天</td>
								</tr>
							</table>
							<span class="fundsum" style="font-size: 12px; float: left;">众筹金额{$v['price']}元/份</span>
				    	{if condition="$v['status']"}
				    		<!-- <button id="btn_zc" onclick="order({$v['type_id']})">众筹</button> -->
				    		<button class="btn_zc" onclick="funds(this,{$v['price']},{$v['type_id']})">众筹</button>
				    	{else/}
				    		<button style="background: gray;" disabled>已下架</button>
				    	{/if}
				    	</div>
						{/foreach}
	            	</div>
	        	</div>
	        	{/if}
	        	{/foreach}
			</div>
			<ul class="click Prepare_position" id='earnings_click'>
				<li class="btn_service"><img src="/static/img/service.png" alt="客服" /><br />客服</li>
				<li class="app_red_letter_btn"><img src="/static/img/new_hand.png" alt="新手" /><br />新手</li>
				<li class="app_red_letter_btn"><img src="/static/img/letter、.png" alt="信" /><br />信</li>
			</ul>
		</div>	
	</div>
{/block}
{block name='box'}
	<div class="big">
		<div class="rgerster">
			<h3>注册新用户</h3>
			<div class="gb">
				<img src="/static/img/cancel.png"/>
			</div>
			<div>
				<p><span>*</span>手机号</p>
				<input type="text" name="mobile" placeholder="请输入您的手机号"/>	
			</div>
			<div>
				<div onclick="verifyimg('{:captcha_src()}')"><img src="{:captcha_src()}" class="verifyimg" alt="captcha" style="display: inline-block;float: right;" /></div>
				<input type="text" name="verify" style="width: 30%;margin: 0 0 0 -20px" placeholder="请输入验证码"/>		
			</div>
			<div>
				<span style="color: red;">*</span>
				<input type="text" style="width: 49%;" name = "code" placeholder="请输入短信" />
				<input type="button" value="发送验证码" style="width: 30%;margin: 10px 0 0 5% 
					background: #FFFFFF;text-indent:5px;" onclick='code(this,"{:url('index/index/code')}","{:captcha_src()}")' />				
			</div>
			<div>
				<p><span>*</span>登录密码</p>
				<input type="password" name="password" placeholder="首字母为大写的8-18位字符" />	
			</div>
			<div>
				<p><span>*</span>重复密码</p>
				<input type="password" name="rpwd" placeholder="请再次输入密码"/>
			</div>
			<div>
				<p><span>*</span>推荐人</p>
				<input type="text" name = 'pmobile' placeholder="推荐人手机号"/>	
			</div>
			<div >
				<p>微信/QQ</p>
				<input type="text" name="QQaccount"  placeholder="请输入您的微信号或QQ号"/>				
			</div>
			<div class="dxk" style="margin: -20px 0 0 0;">
				<input type="checkbox" name="read" value="Y" style="width: 12px;"  style="display: inline-block;margin:  0 0 0 20px;"/>
				<p class="wf">我已阅读并同意（服务协议）</p>
			</div>
			<div>
				<button onclick='signup(this,"{:url('index/index/signup')}")'>确认</button>				
			</div>
		</div>
	</div>
{/block}
{block name='script'}
<script src="/static/js/Octen_center.js"></script>
<script type="text/javascript">

	function funds(iet,price,id)
	{
		var _this = $(iet);
		var v = $('.tosum').text(price);
		$('input[name=type_id]').val(id);
		$('.pay').css('display','block');
	}

    $(function(){
    	  //注册 部分

    	// 
   	  	var txt = $('.txt');
   	  	var txts = $('.txts');
   	  	var p = $('#div_p');
   	  	var index= 0;
   	  	var i=0;
   	  	var pay_body_p = $('#pay_body_p');
       	var pay = $('.pay');
      	var gb = $('#pay_gb');

     	gb.click(function(){
     		pay.css('display','none')
     	})

   	  	txt.click(function(){
   	  		index++;
   	  		p.text(index);
   	  		var sum = $('.tosum').text();
   	  		i++;
   	  		// i += 1999;
   	  		pay_body_p.text(i*sum);
   	  	})
   	  	var pay_body_p = $('#pay_body_p');
   	  	
   	  	txts.click(function(){
   	  		if(p[0].innerHTML==0){
   	  			return;
   	  		}else{
   	  			index--;
       	  		p.text(index);
       	  		var sum = $('.tosum').text();
       	  		i--;
       	  		pay_body_p.text(i*sum);
   	  		}
   	  	})
       	//单选框
       	var radio = $('.radio');
       	var radioimg = $('.radio_img');

   		radio.click(function(){
   			$(this).css('display','none');
   			radioimg.css('display','inline-block');
   			radio.attr('checked',true);
   		})

   		radioimg.click(function(){
   			$(this).css('display','none');
   			radio.css('display','inline-block');
   			radio.attr('checked',false);
   		})
   	})
   	function tofunds(){
   		var num = $('#div_p').text();
   		var id = $("input[name=type_id]").val();
   		var pwd = $("input[name=pwd]").val();
   		var sta = $('.radio').attr('checked');
   		var own;
   		if(sta){
   			own = $('input[name=own').val();
   		}else{
   			own = 0;
   		}
   		$.post(
   			"{:url('tofunds')}",
   			{
   				sum : num,
   				type_id : id,
   				busspwd : pwd,
   				cmsn : own
   			},
   			function (data) {
   				layer.msg(data.msg, { icon: 6, time: 1000 });
	            if (data.code) {
	                setTimeout(function() {
	                    history.go(0);
	                }, 500);
	            }
   			});
    	return false;
   	}
</script>
<script src="/static/js/home_page.js"></script>


{/block}